import { createRouter, createWebHistory } from 'vue-router';
import Home from '../views/Home.vue';
import Detail from '../views/Detail.vue';

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/detail/:type/:value',
    name: 'Detail',
    component: Detail,
    props: true
  },
  {
    path: '/detail/sales_stages',
    name: 'MultiStagesDetail',
    component: Detail,
    props: route => ({
      type: 'sales_stages',
      value: route.query.stages
    })
  },
  {
    path: '/detail/search',
    name: 'SearchDetail',
    component: Detail,
    props: route => ({
      type: 'search',
      value: route.query.keyword
    })
  },
  {
    path: '/detail/month',
    name: 'MonthDetail',
    component: Detail,
    props: route => ({
      type: 'month',
      value: route.query.month
    })
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

export default router; 